layui.config({
    base: 'assets/layuiadmin/' //静态资源所在路径
}).extend({
    index: 'lib/index', //主入口模块
}).use(['index', 'form', 'laytpl', 'element'], function(){
    var $ = layui.$,
        form = layui.form,
        element = layui.element;

    var id = $('#id').val();

    element.render();
    element.on('tab(component-tabs-brief)', function(obj){
        if(this.innerHTML == '基本信息'){
            getUserInfo();
        }else if(this.innerHTML == '金币明细'){
            $('#coin-iframe').attr('src', '/toCoinManage?height=750&userId='+id);
        }else if(this.innerHTML == '积分明细'){
            $('#credit-iframe').attr('src', '/toCreditManage?height=750&userId='+id);
        }else if(this.innerHTML == '视频通话明细'){
            $('#call-iframe').attr('src', '/toCallManage?height=750&fromUserId='+id);
        }else if(this.innerHTML == 'im消息明细'){
            $('#im-iframe').attr('src', '/toImDetailManage?height=750&fromUserId='+id);
        }
    });

    //初始化个人信息页面
    getUserInfo();
    function getUserInfo(){
        var data = {'id': id};
        post('user/toEdit', data, false,function (data) {
            var user = data.user;
            $('#userId').val(user.id);
            $('#name').val(user.name);
            if(user.gender == 0){
                $('input[name=gender][value="0"]').attr('checked', true);
            }else if(user.gender == 1){
                $('input[name=gender][value="1"]').attr('checked', true);
            }else if(user.gender == null || user.gender == ''){
                $('input[name=gender][value=""]').attr('checked', true);
            }
            $('#iconImg').attr('src', ossDomain + '/' + user.icon);
            $('#icon').val(user.icon);
            $('#phone').val(user.phone);
            $('#birthday').val(user.birthday);
            $('#uss_id').val(user.uss_id);
            $('#height').val(user.height);
            $('#weight').val(user.weight);
            $('#pro_id').val(user.pro_id);
            $('#em_id').val(user.em_id);
            $('#level').val(user.level);
            $('#persionSign').val(user.persionSign);
            form.render();
        });
    }
});